bitkeeper revision 1.1108.1.21 (4104ffcb0fLoE7HIdNvUGJI49n_Sxg)
authortw275@labyrinth.cl.cam.ac.uk <tw275@labyrinth.cl.cam.ac.uk>
Mon, 26 Jul 2004 12:57:47 +0000 (12:57 +0000)
committertw275@labyrinth.cl.cam.ac.uk <tw275@labyrinth.cl.cam.ac.uk>
Mon, 26 Jul 2004 12:57:47 +0000 (12:57 +0000)
Added menu writing, improving the menu on the left of the page,
and gerneralized getDomInfoHash, should work with upgraded versions
 of xend

.rootkeys
tools/python/xen/sv/DomInfo.py
tools/python/xen/sv/DomList.py
tools/python/xen/sv/Main.py
tools/python/xen/sv/NodeInfo.py
tools/python/xen/sv/util.py
tools/sv/Makefile
tools/sv/images/pause.png [new file with mode: 0644]
tools/sv/images/unpause.png [new file with mode: 0644]

index 053bb5cede00e2ba7ed0926061aa64f510cc338d..b888478532a9d597d787b2899fd548cc9c900e5e 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg
 40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg
 40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg
+4104ffca9_GhWOxRE-83uZIad2Z1gg tools/sv/images/pause.png
 41013a82ILk71xLqWFH5ZO5VmOIvBw tools/sv/images/reboot.png
 40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg
 40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg
 40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg
 40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg
 41013a82sUdUqBv8EoAUJii3gsZ-4g tools/sv/images/shutdown.png
+4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png
 40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png
 41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js
 40fcefb3zGC9XNBkSwTEobCoq8YClA tools/sv/inc/style.css
index a718871fd55e7f17902529be6b1d58056350a12b..7e23ab792d001a123e08c37d41d6222bdd2190dc 100755 (executable)
@@ -26,6 +26,9 @@ class DomInfo( GenTabbed ):
             self.dom = dom[0]
         
         GenTabbed.write_BODY( self, request )
+        
+    def write_MENU( self, request ):
+        pass
 
 class DomGeneralTab( CompositeTab ):
     def __init__( self ):
@@ -86,15 +89,37 @@ class DomSXPTab( PreTab ):
 class DomActionTab( ActionTab ):
 
     def __init__( self ):
-        ActionTab.__init__( self, { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
-               "reboot" : ( "Reboot the Domain", "reboot.png" ) } )    
+       actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
+                   "reboot" : ( "Reboot the Domain", "reboot.png" ),
+                    "pause" : ( "Pause the Domain", "pause.png" ),
+                    "unpause" : ( "Unpause the Domain", "unpause.png" ) }
+        ActionTab.__init__( self, actions )    
         
     def op_shutdown( self, request ):
-       print ">DomShutDown"
+       dom = getVar( 'dom', request )
+        if not dom is None:
+          print ">DomShutDown %s" % dom
        #server.xend_node_shutdown()
     
     def op_reboot( self, request ):
-       print ">DomReboot"
+               dom = getVar( 'dom', request )
+        if not dom is None:
+           print ">DomReboot %s" % dom
         #server.xend_node_reboot()
         
+    def op_pause( self, request ):
+               dom = getVar( 'dom', request )
+        if not dom is None:
+           print ">DomPause %s" % dom
+            server.xend_domain_pause( int( dom ) )
+        
+    def op_unpause( self, request ):
+               dom = getVar( 'dom', request )
+        if not dom is None:
+          print ">DomUnpause %s" % dom
+           server.xend_domain_unpause( int( dom ) )
+        
+    
+    
+        
 
index ee55957ba6b7c543bdae4c0777897f029622f708..82f7cc424ba6279c92597bade1e93cdf7d844a1f 100755 (executable)
@@ -11,6 +11,9 @@ class DomList( HTMLBase ):
     def __init__( self, urlWriter ):
         HTMLBase.__init__(self)
         self.urlWriter = urlWriter
+        
+    def write_MENU( self, request ):
+       return self.write_BODY( request, head=True, long=False ) 
 
     def write_BODY( self, request, head=True, long=True ):
     
@@ -44,11 +47,9 @@ class DomList( HTMLBase ):
 
         request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
         if long: 
-            request.write( "<td class='domainInfo' align='center'>%(mem)7d</td>\n" % domInfoHash )
-            request.write( "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash )
+            request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash )
+            request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash )
         request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
-        if long:
-            request.write( "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash )
 
     def write_DOMAIN_HEAD( self, request, long=True ):
         request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )      
@@ -57,6 +58,4 @@ class DomList( HTMLBase ):
             request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )      
             request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )      
         request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )      
-        if long:
-            request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" )
             
index 50712c7710b082b33ece7fb872b4559cc720f963..9de097a1d46ece97936483cef8e89d89a77d170f 100755 (executable)
@@ -38,14 +38,13 @@ class Main( HTMLBase ):
         request.write( " <td width='15px'>&nbsp;</td>" )
         request.write( " <td width='175px' align='center' valign'center'>" )
         request.write( "  <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
-        request.write( "   <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
-        request.write( "   <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" )
+        request.write( "   <tr><td height='140px' align='center' valign='bottom'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
+        request.write( "   <img src='images/xen.png' width='150' height='75' border='0'/></a><br/></td></tr>" )
+        request.write( "   <tr><td height='60px' align='center'><p class='small'>SV Web Interface<br/>(C) <a href='mailto:tw275@cam.ac.uk'>Tom Wilkie</a> 2004</p></td></tr>")
         request.write( "   <tr><td align='center' valign='top'>" )
         
         for (modName, (modTitle, module)) in self.modules.items():
-            request.write( "    <p class='small'><a href='Main.rpy?mod=%s'>%s</a></p>" % (modName, modTitle))
-    
-        DomList( self.mainUrlWriter ).write_BODY( request, True, False )
+            module( self.mainUrlWriter ).write_MENU( request )
 
         request.write( "   </td></tr>" )
         request.write( "  </table>" )
index f13781bf1ab206c22cac1cc6014b52d08da21329..a3aac1d34cf82a04614eeba53d962d0f8f7a483c 100755 (executable)
@@ -11,6 +11,9 @@ class NodeInfo( GenTabbed ):
             return urlWriter( "mod=node%s" % url )
     
         GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] )
+    
+    def write_MENU( self, request ):
+        request.write( "<p class='small'><a href='%s'>Node details</a></p>" % self.urlWriter( '' ) )
 
 class NodeGeneralTab( CompositeTab ):
     def __init__( self ):
index 64503bad29ff6d62180322826787a46095d55a77..57940d92878601ff2f81591a21abfa39e8ddc05b 100755 (executable)
@@ -2,26 +2,21 @@ from xen.xend.XendClient import server
 from xen.xend import sxp
 from xen.xend import PrettyPrint
 
+import types
+
 def getDomInfoHash( domain ):
-    domInfo = server.xend_domain( int( domain ) )
-    d = {}
-    d['dom']    = int( domain )
-    d['name']   = sxp.child_value( domInfo, 'name' )
-    d['mem']    = int( sxp.child_value( domInfo, 'memory' ) )
-    d['cpu']    = int( sxp.child_value( domInfo, 'cpu' ) )
-    d['state']  = sxp.child_value( domInfo, 'state' )
-    d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) )
-    if( sxp.child_value( domInfo, 'up_time' ) ):
-        d['up_time'] =  float( sxp.child_value( domInfo, 'up_time' ) )
-    if( sxp.child_value( domInfo, 'start_time' ) ):
-        d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) )
-    return d
+    domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
+    domInfoHash['dom'] = int( domain )
+    return domInfoHash
 
 def sxp2hash( s ):
     sxphash = {}
         
     for child in sxp.children( s ):
-        sxphash[ child[0] ] = child[1]
+       if child is types.ListType:
+            sxphash[ child[0] ] = sxp2hash( child[1] )
+        else:
+            sxphash[ child[0] ] = child[1]
         
     return sxphash
     
@@ -33,9 +28,19 @@ def sxp2string( sxp ):
                 self.str = self.str + str
     temp = tmp()
     PrettyPrint.prettyprint( sxp, out=temp )
-    return temp.str    
+    return temp.str
+
+def getVar( var, request ):
+   
+    arg = request.args.get( var )
+
+    if arg is None or len(arg) != 1:
+        return None
+    else:
+        return arg[0]
 
 def bigTimeFormatter( time ):
+    time = float( time )
     weeks = time // 604800
     remainder = time % 604800
     days = remainder // 86400
@@ -47,6 +52,7 @@ def bigTimeFormatter( time ):
     return "%d weeks, %d days, %s" % ( weeks, days, hms )
 
 def smallTimeFormatter( time ):
+    time = float( time )
     hours = time // 3600
     remainder = time % 3600
     mins = remainder // 60
@@ -56,12 +62,14 @@ def smallTimeFormatter( time ):
 def stateFormatter( state ):
     states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ]
     
+    stateStr = ""
+    
     for i in range( len( state ) ):
         if state[i] != "-":
-            return states[ i ] + " (%s)" % state
-    
-    return state
-    
+            stateStr += "%s, " % states[ i ] 
+           
+    return stateStr + " (%s)" % state
+
 def memoryFormatter( mem ):
     mem = int( mem )
     if mem >= 1024:
@@ -71,6 +79,7 @@ def memoryFormatter( mem ):
         return "%7dMb" % mem
 
 def cpuFormatter( mhz ):
+    mhz = int( mhz )
     if mhz > 1000:
         ghz = float( mhz ) / 1000.0
         return "%4.2fGHz" % ghz
index db432d18bed1c55d3e27ae0ba2a7ba0ef38f7859..8a63d4ac1b396e17e46613d62e23ce71d3cf21cc 100755 (executable)
@@ -31,6 +31,8 @@ install:
        
        install -m0644 images/shutdown.png $(sv_insdir)/images
        install -m0644 images/reboot.png $(sv_insdir)/images
+       install -m0644 images/pause.png $(sv_insdir)/images
+       install -m0644 images/unpause.png $(sv_insdir)/images
 
        # make include folder
        mkdir -p $(sv_insdir)/inc
diff --git a/tools/sv/images/pause.png b/tools/sv/images/pause.png
new file mode 100644 (file)
index 0000000..6e16daa
Binary files /dev/null and b/tools/sv/images/pause.png differ
diff --git a/tools/sv/images/unpause.png b/tools/sv/images/unpause.png
new file mode 100644 (file)
index 0000000..c971308
Binary files /dev/null and b/tools/sv/images/unpause.png differ